* FILE NAME : PREG401.PRG
*

STORE 0 TO CNT,CR
SELE 2
SET EXCLU OFF
* use &dr&F2 inde &dr&F21
SET INDE TO &DR&F21
GO TOP
seek ALLTRIM(compin)
if .not. eof()
   DO WHILE left(comp_name,LEN(ALLTRIM(COMPIN)))=ALLTRIM(COMPIN)
      CNT=CNT+1
      skip
   ENDDO
   cnt=cnt+1
   IF CNT=0
      RETURN
   ENDIF
   DECLARE FILD[CNT]
   DECLARE KODE[CNT]
   DECLARE CNAM[CNT]
   SELE 2
   GO TOP
   seek ALLTRIM(COMPIN)
   if .not. eof()
      DO WHILE left(comp_name,LEN(ALLTRIM(COMPIN)))=ALLTRIM(COMPIN)
         CR=CR+1
         FILD[CR]=COMP_CODE+'   '+COMP_NAME
         KODE[CR]=COMP_CODE
         CNAM[CR]=COMP_NAME
         SKIP
      ENDDO
      cr=cr+1
*      fild[cr]='0000    Unlisted Company'
*      kode[cr]='0000'
*      cnam[cr]=space(32)
   endif
   set colo to w/b
   inkey()
   set colo to w+/rb,gr+/r
   @ 13,37 clea to 23,78
   @ 13,37 to 23,78 double
   pilih=achoice(14,39,22,76,FILD)
   IF LASTKEY()=13
      DARF=FILD[PILIH]
      COCOD=KODE[PILIH]
      CONAM=CNAM[PILIH]
   else
      return
   ENDIF
else
* Buu - remove enter new company name with no company code
   return
   cocod='0000'
   conam=space(32)
endif
